package com.yt.order.service;

import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import javax.annotation.Resource;
import com.yt.order.common.config.YmlConfig;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yt.order.mapper.WorkOrderInfoMapper;
import com.yt.order.models.service.IWorkOrderInfoService;
import com.yt.order.models.bo.WorkOrderInfoSaveBO;
import com.yt.order.models.dto.WorkOrderInfoDTO;

/**
 * 工单信息控制器
 *
 * @author yzz
 * &#064;Date  2025-09-03 14:18:55
 */
@DubboService
public class WorkOrderInfoServiceImpl extends ServiceImpl<WorkOrderInfoMapper, WorkOrderInfoDTO> implements IWorkOrderInfoService{

    @Resource
    private YmlConfig ymlConfig;

    @Override
    public boolean add(WorkOrderInfoSaveBO saveBO) {
        WorkOrderInfoDTO dto = new WorkOrderInfoDTO();
        BeanUtils.copyProperties(saveBO,dto);
        Long id = ymlConfig.getPkId();
        dto.setId(id);
        return this.insert(dto);
    }
    
    @Override
    public boolean assignOrder(Long id, Long dispatcherId, Long employeeId) {
        WorkOrderInfoDTO dto = new WorkOrderInfoDTO();
        dto.setId(id);
        dto.setDispatcherId(dispatcherId);
        dto.setEmployeeId(employeeId);
        dto.setStatus(1); // 设置为处理中状态
        return this.updateById(dto);
    }
}
